local wushen = fk.CreateSkill{
  name = "sr__wushen",
  tags = {Skill.Compulsory}
}

Fk:loadTranslationTable{
  ["sr__wushen"] = "武神",
  [":sr__wushen"] = "锁定技，若你需要使用【杀】，你的<font color=\"#CC3131\">♥</font>牌视为无次数限制的【杀】。",
}

wushen:addEffect("filter", {
  card_filter = function (self, card, player, isJudgeEvent)
    if not player:hasSkill(wushen.name) or card.suit ~= Card.Heart  then return end
    if player:getMark("sr__wushen") > 0  then
      return true
    elseif Fk:currentRoom().current == player and player.phase == Player.Play then
      local c = Fk:cloneCard("slash", card.suit, card.number)
      c:addSubcards(card)
      c.skillName = wushen.name
      return player:canUse(c, {bypass_times = false, bypass_distances = false})
    end
  end,
  view_as = function (self, player, card)
    local c = Fk:cloneCard("slash", card.suit, card.number)
    c:addSubcard(card)
    c.skillName = wushen.name
    return c
  end,
  
})

wushen:addEffect(fk.AskForCardUse, {
  is_delay_effect = true,
  can_refresh = function (self, event, target, player, data)
    local c = Fk:cloneCard("slash")
    c.skillName = wushen.name
    return target == player and player:hasSkill(self) and data.pattern and Exppattern:Parse(data.pattern):match(c)
  end,
  on_refresh = function (self, event, target, player, data)
    print("fuckYoka")
    player.room:setPlayerMark(player, "sr__wushen", 1)
  end
})

--wushen:addEffect(fk.AskForCardResponse, {
--  is_delay_effect = true,
--  can_refresh = function (self, event, target, player, data)
--    local c = Fk:cloneCard("slash")
--    c.skillName = wushen.name
--    return target == player and player:hasSkill(self) and data.pattern and Exppattern:Parse(data.pattern):match(c)
--  end,
--  on_refresh = function (self, event, target, player, data)
--    player.room:setPlayerMark(player, "sr__wushen", 1)
--  end
--})

--wushen:addEffect(fk.CardRespondFinished, {
--  is_delay_effect = true,
--  can_refresh = function (self, event, target, player, data)
--    return target == player and player:hasSkill(self)
--  end,
--  on_refresh = function (self, event, target, player, data)
--    player.room:setPlayerMark(player, "sr__wushen", 0)
--  end
--})

wushen:addEffect(fk.CardUseFinished, {
  is_delay_effect = true,
  can_refresh = function (self, event, target, player, data)
    return target == player and player:hasSkill(self)
  end,
  on_refresh = function (self, event, target, player, data)
    player.room:setPlayerMark(player, "sr__wushen", 0)
  end
})

wushen:addEffect(fk.PreCardUse, {
  mute = true,
  is_delay_effect = true,
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(wushen.name) and table.contains(data.card.skillNames, wushen.name)
  end,
  on_use = function (self, event, target, player, data)
    data.extraUse = true
  end
})

return wushen